//
//  ZJSetVC.m
//  这家测试项目
//
//  Created by IOS_DEVELOPER on 2017/7/12.
//  Copyright © 2017年 陈志凌. All rights reserved.
//

#import "ZJSetVC.h"
#import "ZJQuestionVC.h"
@interface ZJSetVC ()
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
@property (strong, nonatomic)UIAlertController *alertController;
@end

@implementation ZJSetVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.versionLabel.text = [Utils appVersion];
}

- (IBAction)questionBtn:(UIButton *)sender {
    ZJQuestionVC *vc = [[UIStoryboard storyboardWithName:@"Home" bundle:nil] instantiateViewControllerWithIdentifier:@"ZJQuestionVC"];
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)signOutBtn:(UIButton *)sender {
    
    self.alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否退出登录" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        [self.alertController dismissViewControllerAnimated:YES completion:nil];
    }];
    
    [self.alertController addAction:resetAction];
    UIAlertAction *resetAction1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [USER_DEFAULTS removeObjectForKey:@"user_id"];
        [USER_DEFAULTS removeObjectForKey:@"verify"];
        [USER_DEFAULTS removeObjectForKey:@"allConstProjectid"];
        [USER_DEFAULTS removeObjectForKey:@"projArr"];
        [USER_DEFAULTS removeObjectForKey:@"activity_id"];
        [USER_DEFAULTS synchronize];
        allConstProjectid = nil;
        allConstMemberid = nil;
        allConstMD5id = nil;
        UINavigationController *nvc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
        [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:nvc animated:YES completion:^{}];
        
    }];
    
    [self.alertController addAction:resetAction1];
    [self presentViewController:_alertController animated:YES completion:nil];
    
}
-(void)hide{
    
    [self.alertController dismissViewControllerAnimated:YES completion:nil];
    
}@end
